home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Translation.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  11.9 KB  |  306 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Translation.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __TRANSLATION__
  18. #define __TRANSLATION__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __FILES__
  27. #include <Files.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <OSUtils.h>                                        */
  31. /*        #include <Memory.h>                                        */
  32.  
  33. #ifndef __COMPONENTS__
  34. #include <Components.h>
  35. #endif
  36.  
  37. #ifndef __TRANSLATIONEXTENSIONS__
  38. #include <TranslationExtensions.h>
  39. #endif
  40. /*    #include <Quickdraw.h>                                        */
  41. /*        #include <QuickdrawText.h>                                */
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if GENERATINGPOWERPC
  48. #pragma options align=mac68k
  49. #endif
  50.  
  51. #ifdef __CFM68K__
  52. #pragma lib_export on
  53. #endif
  54.  
  55. typedef short DocOpenMethod;
  56.  
  57.  
  58. enum {
  59.     domCannot,
  60.     domNative,
  61.     domTranslateFirst,
  62.     domWildcard
  63. };
  64.  
  65. /* 0L terminated array of OSTypes, or FileTypes*/
  66. typedef OSType TypesBlock[64];
  67.  
  68. typedef OSType *TypesBlockPtr;
  69.  
  70. /* Progress dialog resource ID*/
  71.  
  72. enum {
  73.     kTranslationScrapProgressDialogID = -16555
  74. };
  75.  
  76. /* block of data that describes how to translate*/
  77. struct FileTranslationSpec {
  78.     OSType                            componentSignature;
  79.     const void                        *translationSystemInfo;
  80.     FileTypeSpec                    src;
  81.     FileTypeSpec                    dst;
  82. };
  83. typedef struct FileTranslationSpec FileTranslationSpec;
  84.  
  85. typedef FileTranslationSpec *FileTranslationSpecArrayPtr;
  86.  
  87. /*****************************************************************************************
  88. *   GetFileTypesThatAppCanNativelyOpen
  89. *  This routine returns a list of all FileTypes that an application can open by itself
  90. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  91. *             appSignature        signature (creator) of application
  92. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  93. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  94. */
  95. extern pascal OSErr GetFileTypesThatAppCanNativelyOpen(short appVRefNumHint, OSType appSignature, FileType *nativeTypes)
  96.  TWOWORDINLINE(0x701C, 0xABFC);
  97. /*****************************************************************************************
  98. *  ExtendFileTypeList
  99. *  This routine makes a new list of file types that can be translated into a type in the given list
  100. *  Used by StandardFile
  101. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  102. *             numberOriginalTypes        number of file types in orgTypeList
  103. *              extendedTypeList        pointer to a buffer to be filled with file types
  104. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  105. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  106. *             numberExtendedTypes        number of file types put in extendedTypeList
  107. */
  108. extern pascal OSErr ExtendFileTypeList(const FileType *originalTypeList, short numberOriginalTypes, FileType *extendedTypeList, short *numberExtendedTypes)
  109.  TWOWORDINLINE(0x7009, 0xABFC);
  110. /*****************************************************************************************
  111. *  This routine checks if a file can be opened by a particular application.
  112. *  If so, it returns if it needs to be translated first, and if so then how.
  113. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  114. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  115. *  Enter:    targetDocument        document to check if it can be opened
  116. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  117. *             appSignature        signature (creator) of application to open doc
  118. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  119. *             onlyNative            whether to consider if document can be translated before opening
  120. *             howToOpen            pointer to buffer in which to put how the document can be opened
  121. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  122. *  Exit:    howToOpen            whether file needs to be translated to be read
  123. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  124. *             returns                noErr, noPrefAppErr
  125. */
  126. extern pascal OSErr CanDocBeOpened(const FSSpec *targetDocument, short appVRefNumHint, OSType appSignature, const FileType *nativeTypes, Boolean onlyNative, DocOpenMethod *howToOpen, FileTranslationSpec *howToTranslate)
  127.  TWOWORDINLINE(0x701E, 0xABFC);
  128. /*****************************************************************************************
  129. *  GetFileTranslationPaths
  130. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  131. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  132. *  Enter:    srcDoc            source file or NULL for all matches
  133. *             dstDoc            destination FileType or NULL for all matches
  134. *             maxResultCount
  135. *             resultBuffer
  136. *  Exit:    number of paths
  137. */
  138. extern pascal short GetFileTranslationPaths(FSSpec *srcDocument, FileType dstDocType, unsigned short maxResultCount, FileTranslationSpecArrayPtr resultBuffer)
  139.  TWOWORDINLINE(0x7038, 0xABFC);
  140. /*****************************************************************************************
  141. *  GetPathFromTranslationDialog
  142. *  This routine, with a given document, application, and a passed typelist will display the
  143. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  144. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  145. *  The routine returns the translation path information.
  146. *  Enter:    theDocument            FSSpec to document to open
  147. *             theApplication        FSSpec to application to open document
  148. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  149. *                                 you would like the documented translated to.  Order most perferred
  150. *                                 to least.
  151. *  Exit:    howToOpen            Translation method needed to open document
  152. *             howToTranslate        Translation specification
  153. *             returns                Any errors that might occur.
  154. */
  155. extern pascal OSErr GetPathFromTranslationDialog(const FSSpec *theDocument, const FSSpec *theApplication, TypesBlockPtr typeList, DocOpenMethod *howToOpen, FileTranslationSpec *howToTranslate)
  156.  TWOWORDINLINE(0x7037, 0xABFC);
  157. /*****************************************************************************************
  158. *   TranslateFile
  159. *  This routine reads a file of one format and writes it to another file in another format. 
  160. *  The information on how to translated is generated by the routine CanDocBeOpened.
  161. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  162. *  The destination file must not exist.  It is created by this routine.  
  163. *  Enter:    sourceDocument            input file to translate
  164. *             destinationDocument        output file of translation
  165. *             howToTranslate            pointer to info on how to translate
  166. *  Exit:    returns                    noErr, badTranslationSpecErr 
  167. */
  168. extern pascal OSErr TranslateFile(const FSSpec *sourceDocument, const FSSpec *destinationDocument, const FileTranslationSpec *howToTranslate)
  169.  TWOWORDINLINE(0x700C, 0xABFC);
  170. /*****************************************************************************************
  171. *   GetDocumentKindString
  172. *  This routine returns the string the Finder should show for the "kind" of a document
  173. *  in the GetInfo window and in the kind column of a list view.  
  174. *  Enter:    docVRefNum        The volume containing the document
  175. *             docType            The catInfo.fdType of the document
  176. *             docCreator        The catInfo.fdCreator of the document
  177. *             kindString        pointer to where to return the string
  178. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  179. *             returns            noErr, or afpItemNoFound if kind could not be determined
  180. */
  181. extern pascal OSErr GetDocumentKindString(short docVRefNum, OSType docType, OSType docCreator, Str63 kindString)
  182.  TWOWORDINLINE(0x7016, 0xABFC);
  183. /*****************************************************************************************
  184. *  GetTranslationExtensionName
  185. *  This routine returns the translation system name from a specified TranslationSpec
  186. *  Enter:    translationMethod    The translation path to get the translation name from
  187. *  Exit:    extensionName        The name of the translation system
  188. *             returns                Any errors that might occur
  189. */
  190. extern pascal OSErr GetTranslationExtensionName(const FileTranslationSpec *translationMethod, Str31 extensionName)
  191.  TWOWORDINLINE(0x7036, 0xABFC);
  192. /*****************************************************************************************
  193. *  GetScrapDataProcPtr
  194. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  195. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  196. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  197. *  with a list all the formats that you have available to be translated, and the length of each.
  198. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  199. *  the formats that 'fmts' list said was available.
  200. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  201. *             dataH                    Handle in which to put the requested data
  202. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  203. *             
  204. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  205. */
  206. typedef pascal OSErr (*GetScrapDataProcPtr)(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  207.  
  208. #if GENERATINGCFM
  209. typedef UniversalProcPtr GetScrapDataUPP;
  210. #else
  211. typedef GetScrapDataProcPtr GetScrapDataUPP;
  212. #endif
  213.  
  214. enum {
  215.     uppGetScrapDataProcInfo = kPascalStackBased
  216.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  217.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ScrapType)))
  218.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
  219.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*)))
  220. };
  221.  
  222. #if GENERATINGCFM
  223. #define NewGetScrapDataProc(userRoutine)        \
  224.         (GetScrapDataUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  225. #else
  226. #define NewGetScrapDataProc(userRoutine)        \
  227.         ((GetScrapDataUPP) (userRoutine))
  228. #endif
  229.  
  230. #if GENERATINGCFM
  231. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)        \
  232.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  233. #else
  234. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)        \
  235.         (*(userRoutine))((requestedFormat), (dataH), (srcDataGetterRefCon))
  236. #endif
  237.  
  238. typedef GetScrapDataUPP GetScrapData;
  239.  
  240. /*****************************************************************************************
  241. *  TranslateScrap
  242. *  This routine resizes the destination handle and fills it with data of the requested format.
  243. *  The data is generated by translated one or more source formats of data supplied by
  244. *  the procedure srcDataGetter.  
  245. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  246. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  247. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  248. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  249. *             destinationFormat            Format of data desired
  250. *             destinationData                Handle in which to store translated data
  251. *             
  252. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  253. */
  254. extern pascal OSErr TranslateScrap(GetScrapData sourceDataGetter, void *sourceDataGetterRefCon, ScrapType destinationFormat, Handle destinationData, short progressDialogID)
  255.  TWOWORDINLINE(0x700E, 0xABFC);
  256.  
  257. #ifdef __CFM68K__
  258. #pragma lib_export off
  259. #endif
  260.  
  261. #if GENERATINGPOWERPC
  262. #pragma options align=reset
  263. #endif
  264.  
  265. #ifdef __cplusplus
  266. }
  267. #endif
  268.  
  269. #endif /* __TRANSLATION__ */
  270.